package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.UserBean;
import com.project.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private IUserService userService;

    @PostMapping("login")
    public UserBean login(String userName, String password, HttpServletRequest request){
        UserBean user = userService.login(userName,password);
        if(user!=null){
            request.getSession().setAttribute("loginUser",user);
        }
        return user;
    }

}
